package com.jxj.interceptor;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.stereotype.Controller;
import org.springframework.web.servlet.HandlerInterceptor;
import org.springframework.web.servlet.ModelAndView;

public class LoginInterceptor implements HandlerInterceptor {
	@Override
	public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler)
			throws Exception {
		//拦截器拦截所有请求，除了logins请求之外
		String uri = request.getRequestURI();
		
		System.out.println(uri+"11");

		if(uri.equals("/CollegeService/login")||uri.equals("/CollegeService/register")){
			return true;
		}else{
			Object object = request.getSession().getAttribute("xuehao");
			if(object !=null){
				return true;
			}
			response.sendRedirect("login.jsp");
			return false;
		}
	}
	
}
